{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1-1 获取地理编码"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.488919,22.250070'"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import requests\n",
    "key = '2b87f041d085c8ce5b087a183a73bf1d'\n",
    "def geo(address:str,city=None)-> dict:\n",
    "    parameters = {'key':key,\n",
    "              'city':city,\n",
    "              'citylist':True,\n",
    "              'address':address\n",
    "             }\n",
    "    r = requests.get(\"https://restapi.amap.com/v3/geocode/geo?parameters\", params=parameters)\n",
    "    data = r.json()['geocodes'][0]['location']\n",
    "    return data \n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.488919,22.250070'"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geo(\"广东省中山市坦洲镇金色名都\",\"中山\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'113.492646,22.245957'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geo(\"广东省中山市界狮南路创益文化园\",\"中山\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'count': '1',\n",
       " 'geocodes': [{'formatted_address': '广东省中山市金色名都',\n",
       "   'country': '中国',\n",
       "   'province': '广东省',\n",
       "   'citycode': '0760',\n",
       "   'city': '中山市',\n",
       "   'district': [],\n",
       "   'township': [],\n",
       "   'neighborhood': {'name': [], 'type': []},\n",
       "   'building': {'name': [], 'type': []},\n",
       "   'adcode': '442000',\n",
       "   'street': [],\n",
       "   'number': [],\n",
       "   'location': '113.488919,22.250070',\n",
       "   'level': '兴趣点'}]}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "parameters = {'key':key,\n",
    "              'city':\"中山\",\n",
    "              'citylist':True,\n",
    "              'address':\"广东省中山市坦洲镇金色名都\"\n",
    "             }\n",
    "\n",
    "r = requests.get(\"https://restapi.amap.com/v3/geocode/geo?parameters\", params=parameters)\n",
    "r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1-2 路径规划"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "key = '2b87f041d085c8ce5b087a183a73bf1d'\n",
    "def walking(origin:str,destination:str)->dict:\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'origin':origin,\n",
    "        'destination':destination,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get(\"https://restapi.amap.com/v3/direction/walking?parameters\",params = parameters)\n",
    "    data = r.json()['route']['paths'][0]['steps']\n",
    "    for i in range(0,len(data)):\n",
    "        print(data[int(i)]['instruction'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "向东北步行113米右转\n",
      "向东步行32米向右前方行走\n",
      "向东南步行44米左转\n",
      "向东步行99米右转\n",
      "沿界狮南路向南步行398米向右前方行走\n",
      "沿环洲南路步行41米左转\n",
      "步行25米向左前方行走\n",
      "沿环洲南路向东步行19米右转\n",
      "沿界狮南路向南步行14米向左前方行走\n",
      "步行20米到达目的地\n"
     ]
    }
   ],
   "source": [
    "walking(geo(\"广东省中山市坦洲镇金色名都\",\"中山\"),geo(\"广东省中山市界狮南路创益文化园\",\"中山\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 行政区域查询"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "def district(keywords,subdistrict=None,page=None,offset=None,extensions='base',filter=None,)->dict:\n",
    "    url = 'https://restapi.amap.com/v3/config/district?parameters'\n",
    "    params={\n",
    "        'key':key,\n",
    "        'keywords':keywords,\n",
    "        'subdistrict':subdistrict,\n",
    "        'page':page,\n",
    "        'offset':offset,\n",
    "        'extensions':extensions,\n",
    "        'filter':filter,\n",
    "        'output':'json'\n",
    "    }\n",
    "    response = requests.get(url,params=params)\n",
    "    data = response.json()\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>citycode</th>\n",
       "      <th>adcode</th>\n",
       "      <th>name</th>\n",
       "      <th>center</th>\n",
       "      <th>level</th>\n",
       "      <th>districts</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0591</td>\n",
       "      <td>350100</td>\n",
       "      <td>福州市</td>\n",
       "      <td>119.306239,26.075302</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0591', 'adcode': '350121', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0593</td>\n",
       "      <td>350900</td>\n",
       "      <td>宁德市</td>\n",
       "      <td>119.527082,26.65924</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0593', 'adcode': '350924', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0597</td>\n",
       "      <td>350800</td>\n",
       "      <td>龙岩市</td>\n",
       "      <td>117.02978,25.091603</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0597', 'adcode': '350881', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0599</td>\n",
       "      <td>350700</td>\n",
       "      <td>南平市</td>\n",
       "      <td>118.178459,26.635627</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0599', 'adcode': '350723', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0592</td>\n",
       "      <td>350200</td>\n",
       "      <td>厦门市</td>\n",
       "      <td>118.11022,24.490474</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0592', 'adcode': '350203', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>0596</td>\n",
       "      <td>350600</td>\n",
       "      <td>漳州市</td>\n",
       "      <td>117.661801,24.510897</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0596', 'adcode': '350629', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0594</td>\n",
       "      <td>350300</td>\n",
       "      <td>莆田市</td>\n",
       "      <td>119.007558,25.431011</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0594', 'adcode': '350302', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0595</td>\n",
       "      <td>350500</td>\n",
       "      <td>泉州市</td>\n",
       "      <td>118.589421,24.908853</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0595', 'adcode': '350526', 'nam...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>0598</td>\n",
       "      <td>350400</td>\n",
       "      <td>三明市</td>\n",
       "      <td>117.635001,26.265444</td>\n",
       "      <td>city</td>\n",
       "      <td>[{'citycode': '0598', 'adcode': '350402', 'nam...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  citycode  adcode name                center level  \\\n",
       "0     0591  350100  福州市  119.306239,26.075302  city   \n",
       "1     0593  350900  宁德市   119.527082,26.65924  city   \n",
       "2     0597  350800  龙岩市   117.02978,25.091603  city   \n",
       "3     0599  350700  南平市  118.178459,26.635627  city   \n",
       "4     0592  350200  厦门市   118.11022,24.490474  city   \n",
       "5     0596  350600  漳州市  117.661801,24.510897  city   \n",
       "6     0594  350300  莆田市  119.007558,25.431011  city   \n",
       "7     0595  350500  泉州市  118.589421,24.908853  city   \n",
       "8     0598  350400  三明市  117.635001,26.265444  city   \n",
       "\n",
       "                                           districts  \n",
       "0  [{'citycode': '0591', 'adcode': '350121', 'nam...  \n",
       "1  [{'citycode': '0593', 'adcode': '350924', 'nam...  \n",
       "2  [{'citycode': '0597', 'adcode': '350881', 'nam...  \n",
       "3  [{'citycode': '0599', 'adcode': '350723', 'nam...  \n",
       "4  [{'citycode': '0592', 'adcode': '350203', 'nam...  \n",
       "5  [{'citycode': '0596', 'adcode': '350629', 'nam...  \n",
       "6  [{'citycode': '0594', 'adcode': '350302', 'nam...  \n",
       "7  [{'citycode': '0595', 'adcode': '350526', 'nam...  \n",
       "8  [{'citycode': '0598', 'adcode': '350402', 'nam...  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "行政区域 = district(keywords='福建',extensions='all',subdistrict=2)\n",
    "df_行政区域_1级 = pd.json_normalize(行政区域[\"districts\"][0]['districts'])\n",
    "display(df_行政区域_1级,)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 搜索POI"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "def poi(keywords,types,city=None,citylimit=None,children=None,page=None,extensions='base',sig=None)->dict:\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'keywords':\"瑞幸咖啡\",\n",
    "        'city':\"广东\",\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get(\"https://restapi.amap.com/v3/place/text?parameters\", params=parameters)\n",
    "    data = r.json()\n",
    "    pois = []\n",
    "    pois.extend(data['pois'])\n",
    "    df_input = pd.DataFrame(pois)\n",
    "    return df_input"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>parent</th>\n",
       "      <th>childtype</th>\n",
       "      <th>name</th>\n",
       "      <th>type</th>\n",
       "      <th>typecode</th>\n",
       "      <th>biz_type</th>\n",
       "      <th>address</th>\n",
       "      <th>location</th>\n",
       "      <th>tel</th>\n",
       "      <th>distance</th>\n",
       "      <th>biz_ext</th>\n",
       "      <th>pname</th>\n",
       "      <th>cityname</th>\n",
       "      <th>adname</th>\n",
       "      <th>importance</th>\n",
       "      <th>shopid</th>\n",
       "      <th>shopinfo</th>\n",
       "      <th>poiweight</th>\n",
       "      <th>photos</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>B0FFKFTZS8</td>\n",
       "      <td>B00141JKC4</td>\n",
       "      <td>202</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>南村镇兴南大道368号万达广场1F层</td>\n",
       "      <td>113.348032,23.006807</td>\n",
       "      <td>18617314707</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.0', 'cost': '21.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>番禺区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>B0FFKJOM0K</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;餐饮相关场所;餐饮相关</td>\n",
       "      <td>050000</td>\n",
       "      <td>diner</td>\n",
       "      <td>梅界路237号奥园广场商业街121号</td>\n",
       "      <td>113.515126,22.282482</td>\n",
       "      <td>18529169274</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.0', 'cost': '17.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>珠海市</td>\n",
       "      <td>香洲区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>B0FFM10GH5</td>\n",
       "      <td>B0FFFOS5AN</td>\n",
       "      <td>202</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>大沥镇广佛路97号美嘉广场首层</td>\n",
       "      <td>113.177044,23.107012</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': [], 'cost': [], 'meal_ordering': '0'}</td>\n",
       "      <td>广东省</td>\n",
       "      <td>佛山市</td>\n",
       "      <td>南海区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>B0FFM0S65G</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>同济西路12号永丰大厦1层正门口</td>\n",
       "      <td>113.104843,23.018748</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': [], 'cost': [], 'meal_ordering': '0'}</td>\n",
       "      <td>广东省</td>\n",
       "      <td>佛山市</td>\n",
       "      <td>禅城区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>B0FFM8OSUR</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>古镇镇中兴大道南1号华艺广场亚朵酒店大堂27DA</td>\n",
       "      <td>113.189526,22.601383</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': [], 'cost': [], 'meal_ordering': '0'}</td>\n",
       "      <td>广东省</td>\n",
       "      <td>中山市</td>\n",
       "      <td>中山市</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>1</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>B0FFJGBKD9</td>\n",
       "      <td>B0FFHGLFI2</td>\n",
       "      <td>202</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;餐饮相关场所;餐饮相关</td>\n",
       "      <td>050000</td>\n",
       "      <td>diner</td>\n",
       "      <td>前进二路流塘商务大厦B座流塘湾购物中心一楼A12铺</td>\n",
       "      <td>113.890741,22.581641</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '3.5', 'cost': '24.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>宝安区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>B0FFJD4OEM</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>高盛大厦</td>\n",
       "      <td>113.321298,23.135921</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '3.5', 'cost': [], 'meal_ordering':...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>天河区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>B0FFM3FC12</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>五桂山街道长命水大街9号广东药科大学中山校区H栋一楼</td>\n",
       "      <td>113.414608,22.477310</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': [], 'cost': [], 'meal_ordering': '0'}</td>\n",
       "      <td>广东省</td>\n",
       "      <td>中山市</td>\n",
       "      <td>中山市</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>B0FFM232DZ</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>常平镇市场路1号(永和大王隔壁)</td>\n",
       "      <td>113.994058,22.974066</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': [], 'cost': [], 'meal_ordering': '0'}</td>\n",
       "      <td>广东省</td>\n",
       "      <td>东莞市</td>\n",
       "      <td>东莞市</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>B0FFLALYFU</td>\n",
       "      <td>B0FFIR09XN</td>\n",
       "      <td>202</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>齐富路明珠路归南1号名汇电脑城一层外1FA003号</td>\n",
       "      <td>113.272173,23.194132</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': [], 'cost': [], 'meal_ordering': '0'}</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>白云区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>B0FFIZI5MP</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>大德路233号爱东精品酒店二楼餐厅</td>\n",
       "      <td>113.261406,23.118262</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': [], 'cost': [], 'meal_ordering': '0'}</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>越秀区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>B0FFJS39AB</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>东沙街道广州圆大厦1层</td>\n",
       "      <td>113.259121,23.050135</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '3.5', 'cost': [], 'meal_ordering':...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>荔湾区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>B0FFJOT0F8</td>\n",
       "      <td>B02F38OY21</td>\n",
       "      <td>202</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;餐饮相关场所;餐饮相关</td>\n",
       "      <td>050000</td>\n",
       "      <td>diner</td>\n",
       "      <td>布吉街道广场路2号中安大厦一层大堂</td>\n",
       "      <td>114.127927,22.607544</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '3.5', 'cost': '20.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>龙岗区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>B0FFJIQXEV</td>\n",
       "      <td>B0FFH1Z5DK</td>\n",
       "      <td>202</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>广州大道中988号圣丰广场北塔一层109自编01号</td>\n",
       "      <td>113.315734,23.138347</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '3.5', 'cost': '20.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>天河区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>B0FFIWQMU9</td>\n",
       "      <td>B0FFG7M9YH</td>\n",
       "      <td>202</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>沙太路668号现象工场1层</td>\n",
       "      <td>113.333936,23.178284</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '3.5', 'cost': '19.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>广州市</td>\n",
       "      <td>白云区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>B0FFJNBXAI</td>\n",
       "      <td>B02F37T14X</td>\n",
       "      <td>202</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>中心区益田路4068号卓越时代广场负一层101-B-1号</td>\n",
       "      <td>114.057465,22.533943</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '4.0', 'cost': '19.00', 'meal_order...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>福田区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>B0FFMB5YW8</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>深南中路6009号</td>\n",
       "      <td>114.029891,22.535713</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': '3.5', 'cost': [], 'meal_ordering':...</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>福田区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[{'url': 'http://store.is.autonavi.com/showpic...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>B0FFM8X179</td>\n",
       "      <td>B0FFG9LHZV</td>\n",
       "      <td>202</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>保税区富林物流大厦b栋</td>\n",
       "      <td>114.045120,22.506771</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': [], 'cost': [], 'meal_ordering': '0'}</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>福田区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>B0FFM1E650</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>招商果岭6栋1123铺</td>\n",
       "      <td>113.858818,22.584051</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': [], 'cost': [], 'meal_ordering': '0'}</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>宝安区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>B0FFLHQQTY</td>\n",
       "      <td>B02F37RL6M</td>\n",
       "      <td>202</td>\n",
       "      <td>瑞幸咖啡</td>\n",
       "      <td>餐饮服务;咖啡厅;咖啡厅</td>\n",
       "      <td>050500</td>\n",
       "      <td>diner</td>\n",
       "      <td>滨河大道9003号湖北大厦北区一楼</td>\n",
       "      <td>114.047409,22.527724</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>{'rating': [], 'cost': [], 'meal_ordering': '0'}</td>\n",
       "      <td>广东省</td>\n",
       "      <td>深圳市</td>\n",
       "      <td>福田区</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "      <td>0</td>\n",
       "      <td>[]</td>\n",
       "      <td>[]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            id      parent childtype  name              type typecode  \\\n",
       "0   B0FFKFTZS8  B00141JKC4       202  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "1   B0FFKJOM0K          []        []  瑞幸咖啡  餐饮服务;餐饮相关场所;餐饮相关   050000   \n",
       "2   B0FFM10GH5  B0FFFOS5AN       202  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "3   B0FFM0S65G          []        []  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "4   B0FFM8OSUR          []        []  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "5   B0FFJGBKD9  B0FFHGLFI2       202  瑞幸咖啡  餐饮服务;餐饮相关场所;餐饮相关   050000   \n",
       "6   B0FFJD4OEM          []        []  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "7   B0FFM3FC12          []        []  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "8   B0FFM232DZ          []        []  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "9   B0FFLALYFU  B0FFIR09XN       202  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "10  B0FFIZI5MP          []        []  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "11  B0FFJS39AB          []        []  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "12  B0FFJOT0F8  B02F38OY21       202  瑞幸咖啡  餐饮服务;餐饮相关场所;餐饮相关   050000   \n",
       "13  B0FFJIQXEV  B0FFH1Z5DK       202  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "14  B0FFIWQMU9  B0FFG7M9YH       202  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "15  B0FFJNBXAI  B02F37T14X       202  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "16  B0FFMB5YW8          []        []  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "17  B0FFM8X179  B0FFG9LHZV       202  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "18  B0FFM1E650          []        []  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "19  B0FFLHQQTY  B02F37RL6M       202  瑞幸咖啡      餐饮服务;咖啡厅;咖啡厅   050500   \n",
       "\n",
       "   biz_type                       address              location          tel  \\\n",
       "0     diner            南村镇兴南大道368号万达广场1F层  113.348032,23.006807  18617314707   \n",
       "1     diner            梅界路237号奥园广场商业街121号  113.515126,22.282482  18529169274   \n",
       "2     diner               大沥镇广佛路97号美嘉广场首层  113.177044,23.107012           []   \n",
       "3     diner              同济西路12号永丰大厦1层正门口  113.104843,23.018748           []   \n",
       "4     diner      古镇镇中兴大道南1号华艺广场亚朵酒店大堂27DA  113.189526,22.601383           []   \n",
       "5     diner     前进二路流塘商务大厦B座流塘湾购物中心一楼A12铺  113.890741,22.581641           []   \n",
       "6     diner                          高盛大厦  113.321298,23.135921           []   \n",
       "7     diner    五桂山街道长命水大街9号广东药科大学中山校区H栋一楼  113.414608,22.477310           []   \n",
       "8     diner              常平镇市场路1号(永和大王隔壁)  113.994058,22.974066           []   \n",
       "9     diner     齐富路明珠路归南1号名汇电脑城一层外1FA003号  113.272173,23.194132           []   \n",
       "10    diner             大德路233号爱东精品酒店二楼餐厅  113.261406,23.118262           []   \n",
       "11    diner                   东沙街道广州圆大厦1层  113.259121,23.050135           []   \n",
       "12    diner             布吉街道广场路2号中安大厦一层大堂  114.127927,22.607544           []   \n",
       "13    diner     广州大道中988号圣丰广场北塔一层109自编01号  113.315734,23.138347           []   \n",
       "14    diner                 沙太路668号现象工场1层  113.333936,23.178284           []   \n",
       "15    diner  中心区益田路4068号卓越时代广场负一层101-B-1号  114.057465,22.533943           []   \n",
       "16    diner                     深南中路6009号  114.029891,22.535713           []   \n",
       "17    diner                   保税区富林物流大厦b栋  114.045120,22.506771           []   \n",
       "18    diner                   招商果岭6栋1123铺  113.858818,22.584051           []   \n",
       "19    diner             滨河大道9003号湖北大厦北区一楼  114.047409,22.527724           []   \n",
       "\n",
       "   distance                                            biz_ext pname cityname  \\\n",
       "0        []  {'rating': '4.0', 'cost': '21.00', 'meal_order...   广东省      广州市   \n",
       "1        []  {'rating': '4.0', 'cost': '17.00', 'meal_order...   广东省      珠海市   \n",
       "2        []   {'rating': [], 'cost': [], 'meal_ordering': '0'}   广东省      佛山市   \n",
       "3        []   {'rating': [], 'cost': [], 'meal_ordering': '0'}   广东省      佛山市   \n",
       "4        []   {'rating': [], 'cost': [], 'meal_ordering': '0'}   广东省      中山市   \n",
       "5        []  {'rating': '3.5', 'cost': '24.00', 'meal_order...   广东省      深圳市   \n",
       "6        []  {'rating': '3.5', 'cost': [], 'meal_ordering':...   广东省      广州市   \n",
       "7        []   {'rating': [], 'cost': [], 'meal_ordering': '0'}   广东省      中山市   \n",
       "8        []   {'rating': [], 'cost': [], 'meal_ordering': '0'}   广东省      东莞市   \n",
       "9        []   {'rating': [], 'cost': [], 'meal_ordering': '0'}   广东省      广州市   \n",
       "10       []   {'rating': [], 'cost': [], 'meal_ordering': '0'}   广东省      广州市   \n",
       "11       []  {'rating': '3.5', 'cost': [], 'meal_ordering':...   广东省      广州市   \n",
       "12       []  {'rating': '3.5', 'cost': '20.00', 'meal_order...   广东省      深圳市   \n",
       "13       []  {'rating': '3.5', 'cost': '20.00', 'meal_order...   广东省      广州市   \n",
       "14       []  {'rating': '3.5', 'cost': '19.00', 'meal_order...   广东省      广州市   \n",
       "15       []  {'rating': '4.0', 'cost': '19.00', 'meal_order...   广东省      深圳市   \n",
       "16       []  {'rating': '3.5', 'cost': [], 'meal_ordering':...   广东省      深圳市   \n",
       "17       []   {'rating': [], 'cost': [], 'meal_ordering': '0'}   广东省      深圳市   \n",
       "18       []   {'rating': [], 'cost': [], 'meal_ordering': '0'}   广东省      深圳市   \n",
       "19       []   {'rating': [], 'cost': [], 'meal_ordering': '0'}   广东省      深圳市   \n",
       "\n",
       "   adname importance shopid shopinfo poiweight  \\\n",
       "0     番禺区         []     []        0        []   \n",
       "1     香洲区         []     []        0        []   \n",
       "2     南海区         []     []        0        []   \n",
       "3     禅城区         []     []        0        []   \n",
       "4     中山市         []     []        1        []   \n",
       "5     宝安区         []     []        0        []   \n",
       "6     天河区         []     []        0        []   \n",
       "7     中山市         []     []        0        []   \n",
       "8     东莞市         []     []        0        []   \n",
       "9     白云区         []     []        0        []   \n",
       "10    越秀区         []     []        0        []   \n",
       "11    荔湾区         []     []        0        []   \n",
       "12    龙岗区         []     []        0        []   \n",
       "13    天河区         []     []        0        []   \n",
       "14    白云区         []     []        0        []   \n",
       "15    福田区         []     []        0        []   \n",
       "16    福田区         []     []        0        []   \n",
       "17    福田区         []     []        0        []   \n",
       "18    宝安区         []     []        0        []   \n",
       "19    福田区         []     []        0        []   \n",
       "\n",
       "                                               photos  \n",
       "0   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "1   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "2                                                  []  \n",
       "3                                                  []  \n",
       "4   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "5   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "6   [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "7                                                  []  \n",
       "8                                                  []  \n",
       "9                                                  []  \n",
       "10  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "11  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "12  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "13  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "14  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "15  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "16  [{'url': 'http://store.is.autonavi.com/showpic...  \n",
       "17                                                 []  \n",
       "18                                                 []  \n",
       "19                                                 []  "
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = poi(\"瑞幸咖啡\",\"广东\")\n",
    "data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# ip定位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [],
   "source": [
    "def ip(ip:str):\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'ip':ip,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get(\"https://restapi.amap.com/v3/ip?parameters\", params=parameters)\n",
    "    data = r.json()\n",
    "    del data['status']\n",
    "    del data['info']\n",
    "    df = [\"省份： %s\"%(data['province']),\"地区：%s\"%(data['city']),\"地理编码：%s\"%(data['adcode']),\"经纬度：%s\"%(data['rectangle'])]\n",
    "    print(\"ip:\"+ip)\n",
    "    for i in df:\n",
    "        print(i)\n",
    "    return"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ip:182.254.192.28\n",
      "省份： 广东省\n",
      "地区：广州市\n",
      "地理编码：440100\n",
      "经纬度：113.1017375,22.93212254;113.6770499,23.3809537\n"
     ]
    }
   ],
   "source": [
    "ip(\"182.254.192.28\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 静态地图"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "def map(location:str,zoom:str):\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'location':location,\n",
    "        'zoom':zoom,\n",
    "    }\n",
    "    r = requests.get(\"https://restapi.amap.com/v3/staticmap?parameters\",  params=parameters)\n",
    "    data = r.url\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'https://restapi.amap.com/v3/staticmap?parameters&key=2b87f041d085c8ce5b087a183a73bf1d&location=113.679287%2C23.632575&zoom=18'"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "map(geo(\"广东省广州市从化区中山大学南方学院\",\"广州\"),18)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 坐标转换 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [],
   "source": [
    "def assistant(locations:str,coordsys:str):\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'coordsys':coordsys,\n",
    "        'locations':locations,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get(\"https://restapi.amap.com/v3/assistant/coordinate/convert?parameters\", params=parameters)\n",
    "    data = r.json()['locations']\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'116.487585177952,39.991754014757;116.487585177952,39.991653917101'"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "assistant(\"116.481499,39.990475|116.481499,39.990375\",'gps')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 天气查询"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [],
   "source": [
    "def weather(city:str):\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'city':city,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get(\"https://restapi.amap.com/v3/weather/weatherInfo?parameters\", params=parameters)\n",
    "    data = r.json()\n",
    "    \n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'count': '2',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'lives': [{'province': '辽宁',\n",
       "   'city': '中山区',\n",
       "   'adcode': '210202',\n",
       "   'weather': '晴',\n",
       "   'temperature': '8',\n",
       "   'winddirection': '西南',\n",
       "   'windpower': '≤3',\n",
       "   'humidity': '38',\n",
       "   'reporttime': '2020-04-23 22:23:40'},\n",
       "  {'province': '广东',\n",
       "   'city': '中山市',\n",
       "   'adcode': '442000',\n",
       "   'weather': '阴',\n",
       "   'temperature': '19',\n",
       "   'winddirection': '西北',\n",
       "   'windpower': '≤3',\n",
       "   'humidity': '85',\n",
       "   'reporttime': '2020-04-23 22:22:50'}]}"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "weather('中山')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 输入提示"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [],
   "source": [
    "def inputtips(keywords:str):\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'keywords':keywords,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get(\"https://restapi.amap.com/v3/assistant/inputtips?parameters\", params=parameters)\n",
    "    data = r.json()\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'count': '5',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'tips': [{'id': 'B02F80P2KX',\n",
       "   'name': '汇乔金色名都',\n",
       "   'district': '广东省中山市',\n",
       "   'adcode': '442000',\n",
       "   'location': '113.488919,22.250585',\n",
       "   'address': '坦洲镇界狮南路30号',\n",
       "   'typecode': '120302',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFG15Q52',\n",
       "   'name': '金色名都',\n",
       "   'district': '湖南省株洲市芦淞区',\n",
       "   'adcode': '430203',\n",
       "   'location': '113.158161,27.821954',\n",
       "   'address': '石宋西路186号',\n",
       "   'typecode': '120302',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFGOEPMZ',\n",
       "   'name': '金色名都停车场',\n",
       "   'district': '广东省中山市',\n",
       "   'adcode': '442000',\n",
       "   'location': '113.489451,22.251298',\n",
       "   'address': '界狮南路附近',\n",
       "   'typecode': '150904',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFG2S7WO',\n",
       "   'name': '金色名都(东门)',\n",
       "   'district': '湖南省株洲市芦淞区',\n",
       "   'adcode': '430203',\n",
       "   'location': '113.158289,27.821931',\n",
       "   'address': '石宋西路168号附近',\n",
       "   'typecode': '991001',\n",
       "   'city': []},\n",
       "  {'id': 'B0FFK60D6C',\n",
       "   'name': '金色名都艾迪儿亲子园',\n",
       "   'district': '广东省中山市',\n",
       "   'adcode': '442000',\n",
       "   'location': '113.490715,22.251281',\n",
       "   'address': '低围街与界狮南路交叉口南150米',\n",
       "   'typecode': '141400',\n",
       "   'city': []}]}"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "inputtips(\"金色名都\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 交通态势"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {},
   "outputs": [],
   "source": [
    "def rectangle(rectangle:str):\n",
    "    parameters = {\n",
    "        'key':key,\n",
    "        'rectangle':rectangle,\n",
    "        'output':'json'\n",
    "    }\n",
    "    r = requests.get(\"https://restapi.amap.com/v3/traffic/status/rectangle?parameters\", params=parameters)\n",
    "    data = r.json()\n",
    "    return data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'status': '1',\n",
       " 'info': 'OK',\n",
       " 'infocode': '10000',\n",
       " 'trafficinfo': {'description': '北四环路：双向畅通。',\n",
       "  'evaluation': {'expedite': '100.00%',\n",
       "   'congested': '0.00%',\n",
       "   'blocked': '0.00%',\n",
       "   'unknown': '0.00%',\n",
       "   'status': '1',\n",
       "   'description': '整体畅通'}}}"
      ]
     },
     "execution_count": 76,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rectangle(\"116.351147,39.9966309;116.357134,39.968727\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 简单app设计"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 寻找失踪的宠物\n",
    "\n",
    "> 调用的API：1.ip定位\n",
    "         2.路径规划\n",
    "         3.静态地图\n",
    "\n",
    "> 设计理念：失踪宠物的主人通过及时上传宠物的照片、详细信息（体积、身体特征、失踪当时穿着等），平台会迅速将寻宠启事，以同心圆的方式将信息向四周扩散，且每两个小时便会扩散方圆50公里。平台会与各大app合作，当其它app用户收到信息提示时，也可以留意附近情况，加大寻宠几率。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
